added dummy model "frequency" and dummy format "frequency float" to be
authorØyvind Kolås <ok@src.gnome.org>
Fri, 13 Jun 2008 20:32:08 +0000 (20:32 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Fri, 13 Jun 2008 20:32:08 +0000 (20:32 +0000)
* extensions/frequency.c: added dummy model "frequency" and dummy
format "frequency float" to be used purely for creating, storing,
accessing but not converting to and from normal tristimulus spaces.
can be used by GeglBuffer to create frequency domain buffers that
are processed in a similar manner to normal buffers.

svn path=/trunk/; revision=339

ChangeLog
extensions/frequency.c [new file with mode: 0644]

index 3660036b59f738ff1573baf2de5e2330f4d6d830..38e744c97c903e9e175e7fcb6aca83eabf9e30f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,18 @@
-2008-02-27  Øyvind Kolås  <pippin@gimp.org>
+2008-06-13  Øyvind Kolås  <pippin@gimp.org>
+
+       * extensions/frequency.c: added dummy model "frequency" and dummy
+       format "frequency float" to be used purely for creating, storing,
+       accessing but not converting to and from normal tristimulus spaces.
+       can be used by GeglBuffer to create frequency domain buffers that
+       are processed in a similar manner to normal buffers.
+
+2008-06-12  Øyvind Kolås  <pippin@gimp.org>
 
        * configure.ac: post release increment of version to 0.0.23
 
 =========================== 0.0.22 released =============================
 
-2008-02-27  Øyvind Kolås  <pippin@gimp.org>
+2008-06-12  Øyvind Kolås  <pippin@gimp.org>
 
        * configure.ac: incremented version.
 
diff --git a/extensions/frequency.c b/extensions/frequency.c
new file mode 100644 (file)
index 0000000..f3cbe1e
--- /dev/null
@@ -0,0 +1,125 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005-2008 Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This file contains a pseudo model and format for storing frequency domain buffers,
+ * the main purpose is registering a fully decorated introspectable format. It currently
+ * provides nop conversions when registering when conversions to or from this conversion
+ * is requested nothing is done.
+ *
+ * Added as a potential aid for summer of code project adding frequency domain processing
+ * to GEGL
+ */
+
+#include "config.h"
+
+#include <math.h>
+#include <string.h>
+
+#include "babl.h"
+
+
+static long  rgba_to_frequency (char *src,
+                                char *dst,
+                                long  n);
+
+static long  frequency_to_rgba (char *src,
+                                char *dst,
+                                long  n);
+
+int init (void);
+
+int
+init (void)
+{
+  babl_component_new ("Rr", NULL);
+  babl_component_new ("Gr", NULL);
+  babl_component_new ("Br", NULL);
+  babl_component_new ("Ar", NULL);
+  babl_component_new ("Ri", NULL);
+  babl_component_new ("Gi", NULL);
+  babl_component_new ("Bi", NULL);
+  babl_component_new ("Ai", NULL);
+
+  babl_model_new (
+    "name", "frequency",
+    babl_component ("Rr"),
+    babl_component ("Gr"),
+    babl_component ("Br"),
+    babl_component ("Ar"),
+    babl_component ("Ri"),
+    babl_component ("Gi"),
+    babl_component ("Bi"),
+    babl_component ("Ai"),
+    NULL
+  );
+
+  babl_conversion_new (
+    babl_model ("RGBA"),
+    babl_model ("frequency"),
+    "linear", rgba_to_frequency,
+    NULL
+  );
+
+  babl_conversion_new (
+    babl_model ("frequency"),
+    babl_model ("RGBA"),
+    "linear", frequency_to_rgba,
+    NULL
+  );
+
+  babl_format_new (
+    "name", "frequency float",
+    babl_model ("frequency"),
+    babl_type ("float"),
+    babl_component ("Rr"),
+    babl_component ("Gr"),
+    babl_component ("Br"),
+    babl_component ("Ar"),
+    babl_component ("Ri"),
+    babl_component ("Gi"),
+    babl_component ("Bi"),
+    babl_component ("Ai"),
+    NULL
+  );
+
+  return 0;
+}
+
+
+static long
+rgba_to_frequency (char *src,
+                   char *dst,
+                   long  n)
+{
+  /* we don't do any conversion, which will be registered as the only valid conversion in babl to go to RGB, it won't work though and
+   * the buffer is left untouched without complaints from babl.
+   */
+  return n;
+}
+
+static long
+frequency_to_rgba (char *src,
+                   char *dst,
+                   long  n)
+{
+  /* we don't do any conversion, which will be registered as the only valid conversion in babl to go to RGB, it won't work though and
+   * the buffer is left untouched without complaints from babl.
+   */
+  return n;
+}